<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>闭包测试</title>
</head>
<body>
    <p>倒计时<span id="time"></span>!</p>
    
    <script>

        var pos = document.getElementById('time');
        // var count = 10;

        function createTimer() {
            var count = 10;
            return function() {
                return count--;
            }
        }

        var timer = createTimer();

        setInterval(function() {
            
            pos.innerHTML = timer();
            // count--;
            // console.log('sss')
        }, 1000);


    </script>
</body>
</html>